//
//  MyImageView.m
//  SuperParents
//
//  Created by a on 2019/10/18.
//  Copyright © 2019 CodeiStrust. All rights reserved.
//

#import "MyImageView.h"

@implementation MyImageView

- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        self.contentMode = UIViewContentModeScaleAspectFill;
        self.clipsToBounds = true;
    }
    return self;
}

- (void)setCornerWithWidths:(CGFloat)width {
    self.layer.cornerRadius = width;
    self.clipsToBounds = true;
}
- (void)setCornerWithWidth:(CGFloat)width {

    UIBezierPath *fieldPath = [UIBezierPath bezierPathWithRoundedRect:self.bounds byRoundingCorners:UIRectCornerAllCorners cornerRadii:CGSizeMake(width, width)];
    CAShapeLayer *fieldLayer = [[CAShapeLayer alloc] init];
    fieldLayer.frame = self.bounds;
    fieldLayer.path = fieldPath.CGPath;
    self.layer.mask = fieldLayer;
}



- (void)setBorderWithWidth:(CGFloat)width andBorderCorlor:(UIColor *)color {
    self.layer.borderWidth = width;
    self.layer.borderColor = color.CGColor;
}

- (void)setImageWithSmallImage:(NSString *)imageName {
    UIImage* img=[UIImage imageNamed:imageName];//原图
    UIEdgeInsets edge=UIEdgeInsetsMake(0, 10, 0,10);
    //UIImageResizingModeStretch：拉伸模式，通过拉伸UIEdgeInsets指定的矩形区域来填充图片
    //UIImageResizingModeTile：平铺模式，通过重复显示UIEdgeInsets指定的矩形区域来填充图
    img= [img resizableImageWithCapInsets:edge resizingMode:UIImageResizingModeStretch];
    self.image=img;
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
